package com.yingside.gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestMainFrame extends JFrame {
    private String username;
    private JTextField txtUsername;
    private JButton btnModify;
    private JTextField txtUser;
    private TestLoginFrame loginFrame;

    public TestMainFrame(TestLoginFrame loginFrame){
        this.loginFrame = loginFrame;
        //this.txtUser = txtUser;
        //this.username = username;
        //this.setTitle("欢迎你：" + this.username);
        this.setTitle("欢迎你：" + loginFrame.getTxtUsername().getText());

        this.setBounds(400,100,400,400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new FlowLayout());
        txtUsername = new JTextField(20);
        txtUsername.setText(loginFrame.getTxtUsername().getText());

        btnModify = new JButton("修改");
        btnModify.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = txtUsername.getText();
                loginFrame.modifyInputField(text);
            }
        });

        this.add(txtUsername);
        this.add(btnModify);
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
